﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using JelloPhysics;
using Microsoft.Xna.Framework;
using System.Drawing;

namespace WinFormDemo
{

    internal class FallingBody : PressureBody
    {
        public FallingBody(World w, ClosedShape s, float massPerPoint, float gasPressure, float shapeSpringK, float shapeSpringDamp, float edgeSpringK, float edgeSpringDamp, Vector2 pos, float angle, Vector2 scale)
            : base(w, s, massPerPoint, gasPressure, shapeSpringK, shapeSpringDamp, edgeSpringK, edgeSpringDamp, pos, angle, scale, false)
        {
        }

        public override void accumulateExternalForces()
        {
            base.accumulateExternalForces();
            for (int i = 0; i < base.mPointMasses.Count; i++)
            {
                PointMass local1 = base.mPointMasses[i];
                local1.Force += new Vector2(0f, -9.8f * base.mPointMasses[i].Mass);
            }
        }
    }

    public class CPoint
    {
        public float X
        {
            get
            {
                return xPos;
            }
        }
        public float Y
        {
            get
            {
                return yPos;
            }
        }

        private float xPos = 0;
        private float yPos = 0;

        public CPoint(double x, double y)
        {
            xPos = (float)x;
            yPos = (float)y;
        }
    }

    public sealed class Polygon
    {
        public Brush Fill = null;   // 填充色
        public Brush Stroke = null; // 边框色
        public float StrokeThickness = 4; // 边框线宽


        private List<CPoint> PointsList = null; // 边界点集

        public List<CPoint> Points
        {
            get
            {
                return PointsList;
            }
            set
            {
                PointsList = value;
            }
        }



    }

    static class Program
    {
        static Form1 mainForm = null;

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            mainForm = new Form1();
            Application.Idle += new EventHandler(Application_Idle);
            Application.Run(mainForm);
        }

        static void Application_Idle(object sender, EventArgs e)
        {
            if (mainForm != null)
            {
                mainForm.Refresh();
            }
        }
    }
}
